﻿@model QuanLySanXuat.Models.OrderProcessFormModels
<script type="text/javascript">
    $(document).ready(function () {
        $(function () {
            $("#SubprocessStartDate").datepicker();
            $("#SubprocessEndDate").datepicker();
            $("#SubprocessStartDate").datepicker("option", "dateFormat", "dd/mm/yy");
            $("#SubprocessEndDate").datepicker("option", "dateFormat", "dd/mm/yy");
        });
    });
</script>
@if (Model != null)
{ 
    <div id="form_body">
        <table id="tblSubprocessDetail">
            <thead>
                <tr>
                    <th style="width: 150px;"><span>Mã chi tiết thiết kế</span></th>
                    <th style="width: 150px;"><span>Bộ phận</span></th>
                    <th style="width: 150px;"><span>Chịu trách nhiệm</span></th>
                    <th style="width: 140px;"><span>Nhà xưởng</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 100px;"><span>Thời gian bắt đầu</span></th>
                    <th style="width: 100px;"><span>Thời gian kết thúc</span></th>
                    <th style="width: 100px;"><span>Trạng thái hoàn thành</span></th>
                    <th style="width: 100px;"><span>Người kiểm tra sản phẩm</span></th>
                    <th style="width: 100px;"><span>KQ chất lượng</span></th>
                    <th style="width: 100px;"><span>KQ công việc</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                @if (Model.SubprocessDetailsFormModels != null)
                {
                    foreach (var item in Model.SubprocessDetailsFormModels)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="SubprocessDetailID" name="SubprocessDetailID" class="SubprocessDetailID" value="@item.ID" />
                             @Html.DropDownList("SubprocessDesignDetailID", new SelectList(ViewData["DesignDetail"] as IEnumerable<Data.Models.DesignDetail>, "ID", "Name", @item.DesignDetail.ID), new { @class = "span2 col-sm-1 form-control" })
                        </td>
                        <td>
                            @Html.DropDownList("SubprocessUnitID", new SelectList(ViewData["Unit"] as IEnumerable<Data.Models.Unit>, "ID", "Name", @item.UnitID), new { @class = "span2 col-sm-1 form-control" })
                        </td>
                        <td>
                            @Html.DropDownList("SubprocessResponsibleID", new SelectList(ViewData["Employee"] as IEnumerable<Data.Models.Employee>, "ID", "Name", @item.ResponsibleID),  new { @class = "span2 col-sm-1 form-control accesscorychange" })
                        </td>
                        <td>
                            @Html.DropDownList("SubprocessWorkplaceID", new SelectList(ViewData["Workplace"] as IEnumerable<Data.Models.Workplace>, "ID", "Name", @item.WorkplaceID),  new { @class = "span2 col-sm-1 form-control accesscorychange" })
                        </td>
                        <td>
                            <input type="text" id="SubprocessQuantity" name="SubprocessQuantity" class="txt1 SubprocessQuantity quantity" value="@item.Quantity">
                        </td>
                        <td>
                            <input type="text" id="SubprocessStartDate" name="SubprocessStartDate" class="txt1 SubprocessStartDate quantity" value="@Convert.ToDateTime(item.StartDate).ToShortDateString()">
                        </td>
                        <td>
                            <input type="text" id="SubprocessEndDate" name="SubprocessEndDate" class="txt1 SubprocessEndDate quantity" value="@Convert.ToDateTime(item.EndDate).ToShortDateString()">
                        </td>
                        <td>
                            @Html.DropDownList("SubprocessState", new SelectList(new List<SelectListItem>{ new SelectListItem() {Text = "Chưa hoàn thành", Value="0"},
                                                                            new SelectListItem() {Text = "Hoàn thành", Value="1"}
                                                                           }, "Value", "Text", @item.State), new { @class = "form-control"})
                            
                        </td>
                        <td>
                            @Html.DropDownList("SubprocessExaminerID", new SelectList(ViewData["Employee"] as IEnumerable<Data.Models.Employee>, "ID", "Name", @item.ExaminerID),  new { @class = "span2 col-sm-1 form-control accesscorychange" })
                        </td>
                        <td>
                            <input type="text" id="SubprocessEvaluation1" name="SubprocessEvaluation1" class="txt1 SubprocessEvaluation1 quantity" value="@item.Evaluation1">
                        </td>
                        <td>
                            <input type="text" id="SubprocessEvaluation2" name="SubprocessEvaluation2" class="txt1 SubprocessEvaluation2 quantity" value="@item.Evaluation2">
                        </td>
                    </tr>
                    }
                }

            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblCostDetail">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Mã chi tiết thiết kế</span></th>
                    <th style="width: 150px;"><span>Chi phí nguyên vật liệu</span></th>
                    <th style="width: 150px;"><span>Chi phí công thợ</span></th>
                    <th style="width: 140px;"><span>Khấu hao công cụ sản xuất</span></th>
                    <th style="width: 50px;"><span>Chi phí sản xuất khác</span></th>
                    <th style="width: 100px;"><span>Tổng chi phí</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                @if (Model.CostDetailsFormModels != null)
                {
                    foreach (var item in Model.CostDetailsFormModels)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="CostDetailID" name="CostDetailID" class="CostDetailID" value="@item.ID"/>
                               @Html.DropDownList("CostDetailDesignDetailID", new SelectList(ViewData["DesignDetail"] as IEnumerable<Data.Models.DesignDetail>, "ID", "Name", @item.DesignDetail.ID), new { @class = "span2 col-sm-1 form-control" })
                        </td>
                        <td>
                            <input type="text" id="CostDetailMaterialCost" name="CostDetailMaterialCost" class="txt1 CostDetailMaterialCost quantity" value="@item.MaterialCost">
                        </td>
                        <td>
                            <input type="text" id="CostDetailLabourCost" name="CostDetailLabourCost" class="txt1 CostDetailLabourCost quantity" value="@item.LabourCost">
                        </td>
                        <td>
                            <input type="text" id="CostDetailToolCost" name="CostDetailToolCost" class="txt1 CostDetailToolCost quantity" value="@item.ToolCost">
                        </td>
                        <td>
                            <input type="text" id="CostDetailOtherCost" name="CostDetailOtherCost" class="txt1 CostDetailOtherCost quantity" value="@item.OtherCost">
                        </td>
                        <td>
                            <input type="text" id="CostDetailTotalCost" name="CostDetailTotalCost" class="txt1 CostDetailTotalCost quantity" value="@item.TotalCost">
                        </td>
                    </tr>
                    }
                }

            </tbody>
        </table>
    </div>
}
<div class="cleardiv"></div>
<div class="btn-group">
    <div class="btn-group">
        <button id="btnSaveSale" type="submit" class="btn btn-defaultxero">Lưu</button>
    </div>
</div>
<div class="btn-group">
    <button id="btnCancelSale" type="button" onclick="javascript: location.href = '/OrderProcess';" class="btn btn-defaultxero">Hủy</button>
</div>
